﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BarberShop.BLL;
using BarberShop.Data;
using Maticsoft.Common;

public partial class MovieAdd : BasePage
{
    public int Id
    {
        get
        {
            return string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"]);
        }
    }
    private MoveInfo _info = new MoveInfo();
    public MoveInfo info
    {
        get { return _info; }
        set { _info = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //GetData();
        string guid = Request.Params["guid"];
        UploadUtil utilHelp = new UploadUtil(this, guid, BarberShop.Common.Enum.MultimediaType.Movie);
        DownloadingFileInfo fileinfo = null;
        bool r = utilHelp.Upload(out  fileinfo);
        if (r && fileinfo != null)//文件上次成功
        {
            string name = Request.Params["txt_movieName"];
            int minuite = Convert.ToInt32(Request.Params["drp_minuite"]);
            int second = Convert.ToInt32(Request.Params["drp_second"]);
            string lastfilename = fileinfo.LastFileName;
            double Size = fileinfo.FileSize;
            MoveInfo info = new MoveInfo();
            info.CreateDate = DateTime.Now;
            info.FileName = lastfilename;
            info.MoveName = name;
            info.Size = Size;
            info.TimeLength = minuite * 60 + second;
            MovieInfoBLL.AddMovieInfo(info);
        }
        //#region 修改
        //else//修改
        //{
        //    string upload_file=Request.Params["upload_file"];
        //    DownloadingFileInfo fileinfo = null;
        //    if (!string.IsNullOrEmpty(upload_file))
        //    {
        //        string guid = Request.Params["guid"];
        //        UploadUtil utilHelp = new UploadUtil(this, guid, BarberShop.Common.Enum.MultimediaType.Movie);
        //        bool r = utilHelp.Upload(out  fileinfo);
        //    }
        //        string name = Request.Params["txt_movieName"];
        //        int minuite = Convert.ToInt32(Request.Params["drp_minuite"]);
        //        int second = Convert.ToInt32(Request.Params["drp_second"]);
        //        info.MoveName = name;
        //        info.TimeLength = minuite * 60 + second;
        //        if (fileinfo != null)
        //        {
        //            string lastfilename = fileinfo.LastFileName;
        //            double Size = fileinfo.FileSize;
        //            info.FileName = lastfilename;
        //            info.Size = Size; 
        //        }
        //        //MovieInfoBLL.UpdateMoveInfo(info);
        //}
        //#endregion
    }

    protected void GetData()
    {
        info = MovieInfoBLL.GetMoveInfo(Id);
    }

}